package com.lagou.edu.utils;

import java.sql.SQLException;

public class TransactionManager {

    private TransactionManager() {

    }

    private static TransactionManager transactionManager = new TransactionManager();

    public static TransactionManager getInstance() {
        return transactionManager;
    }



//    private ConnectionUtils connectionUtils;
//
//    public void setConnectionUtils(ConnectionUtils connectionUtils) {
//        this.connectionUtils = connectionUtils;
//    }

    public void beginTransaction() throws SQLException {
        ConnectionUtils.getInstance().getCurrentThreadConnection().setAutoCommit(false);
    }

    public void commit() throws SQLException {
        ConnectionUtils.getInstance().getCurrentThreadConnection().commit();
    }

    public void rollback() throws SQLException {
        ConnectionUtils.getInstance().getCurrentThreadConnection().rollback();
    }
}
